class ScorePanel{
  // 积分
  private score = 0
  // 当前关卡
  private level = 1
  // 最大关卡
  private maxLevel :number
  // 过关条件
  private num:number

  scoreSpan:HTMLElement
  levelSpan:HTMLElement
  constructor(maxLevel:number = 10,num:number = 10){
    this.scoreSpan = document.getElementById('score')
    this.levelSpan = document.getElementById('level')
    this.maxLevel = maxLevel
    this.num = num
  }
  getScore(){
    return this.score
  }
  addScore(value:Boolean){
    if(!value){
      this.scoreSpan.innerHTML = '0'
    }else{
      this.scoreSpan.innerHTML = ++this.score + ''
      if(this.score % this.num === 0){
      this.addLevel(true)
    }
    }
    
  }
  getLevel(){
    return this.level
  }
 addLevel(value:Boolean){
   if(!value){
    this.levelSpan.innerHTML = '1'
   }else{
     if(this.level <= this.maxLevel){
       this.levelSpan.innerHTML = ++this.level + ''
     }
   }
  }
}
export default ScorePanel